package org.zpmis.config;

import io.minio.MinioClient;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Map;

/**
 * minio 配置类
 */
@Configuration
@ConfigurationProperties(prefix = "minio")
public class MinioConfig {
    /**
     * endPoint是一个URL
     */
    private String endpoint;
    /**
     * accessKey类似于用户ID，用于唯一标识你的账户
     */
    private String accessKey;
    /**
     * secretKey是你账户的密码
     */
    private String secretKey;

    /**
     * 业务和桶的对应关系
     */
    private Map<String,String> businessBucket;

    /**
     * 对外提供服务的网关地址
     * 正常情况 minio不对外网开放
     *例如  gatewayAddress: http://zpmisapi-test.cpzs.org:10086/preview
     */
    private String gatewayAddress;

    @Bean
    public MinioClient getMinClient() {
        return MinioClient.builder()
                .endpoint(endpoint)
                .credentials(accessKey, secretKey)
                .build();
    }

    public String getEndpoint() {
        return endpoint;
    }

    public void setEndpoint(String endpoint) {
        this.endpoint = endpoint;
    }

    public String getAccessKey() {
        return accessKey;
    }

    public void setAccessKey(String accessKey) {
        this.accessKey = accessKey;
    }

    public String getSecretKey() {
        return secretKey;
    }

    public void setSecretKey(String secretKey) {
        this.secretKey = secretKey;
    }

    public Map<String, String> getBusinessBucket() {
        return businessBucket;
    }

    public void setBusinessBucket(Map<String, String> businessBucket) {
        this.businessBucket = businessBucket;
    }

    public String getGatewayAddress() {
        return gatewayAddress;
    }

    public void setGatewayAddress(String gatewayAddress) {
        this.gatewayAddress = gatewayAddress;
    }
}
